package prototype;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.SerializationUtils;

import java.io.*;
import java.lang.reflect.InvocationTargetException;

/**
 * @program: javase
 * @description:
 * @author: luolidong
 * @create: 2021-06-12 21:02
 * @version: 1.0
 */
public class UserTest {
    public static void main(String[] args) throws CloneNotSupportedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        User wife = new User(111,"憨憨",new int[]{4,5,6},null);
        User user = new User(222,"憨批",new int[]{1,2,3},wife);
        User shallow1 = (User) user.clone();
//浅拷贝
        System.out.println("user.hashCode() = " + user);
        System.out.println("clone1.hashCode() = " + shallow1);

//深拷贝
        User deep = user.clone2();
        System.out.println("deep.hashCode() = " + deep);
//使用
//        BeanUtils.copyProperties();
//        System.out.println("BeanUtils"+o);
//        深拷贝
        User serializationUtilsUser = SerializationUtils.clone(user);
        System.out.println("SerializationUtils" +serializationUtilsUser);
    }
}
